package Chepter9;

import java.util.Date;
import java.util.Scanner;

public class Chepter9_9_7 {
	
	static void printMenu(){
		System.out.println("\nMain menu");
		System.out.println("1: check balance");
		System.out.println("2: withdraw");
		System.out.println("3: deposit");
		System.out.println("4: others ID");
		System.out.println("5: exit");
	}
	
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int temp, menu=0;
		
		Account account0 = new Account(0, 10000);
		Account account1 = new Account(1, 10000);
		Account account2 = new Account(2, 10000);
		Account account3 = new Account(3, 10000);
		Account account4 = new Account(4, 10000);
		Account account5 = new Account(5, 10000);
		Account account6 = new Account(6, 10000);
		Account account7 = new Account(7, 10000);
		Account account8 = new Account(8, 10000);
		Account account9 = new Account(9, 10000);
		
		do {
			System.out.print("Emter an id(0~9) : ");
			temp = input.nextInt();
		} while ((temp < 0) || (9 < temp)); // check id
		
		do{
			switch(temp){
			case 0 : 
				printMenu();
				System.out.print("Enter a choice : ");
				menu = input.nextInt();
				switch(menu){
				case 1 : 
					System.out.print("The balance is " + account0.getBalance() + "\n"); break;
				case 2 : 
					System.out.print("Enter an amount to withdraw : ");
					account0.withdraw(input.nextDouble()); break;
				case 3 : 
					System.out.print("Enter an amount to deposit : ");
					account0.deposit(input.nextDouble()); break;
				}
				break;
			case 1 :  
				printMenu();
				System.out.print("Enter a choice : ");
				menu = input.nextInt();
				switch(menu){
				case 1 : 
					System.out.print("The balance is " + account1.getBalance() + "\n"); break;
				case 2 : 
					System.out.print("Enter an amount to withdraw : ");
					account1.withdraw(input.nextDouble()); break;
				case 3 : 
					System.out.print("Enter an amount to deposit : ");
					account1.deposit(input.nextDouble()); break;
				}
				break;
			case 2 :  
				printMenu();
				System.out.print("Enter a choice : ");
				menu = input.nextInt();
				switch(menu){
				case 1 : 
					System.out.print("The balance is " + account2.getBalance() + "\n"); break;
				case 2 : 
					System.out.print("Enter an amount to withdraw : ");
					account2.withdraw(input.nextDouble()); break;
				case 3 : 
					System.out.print("Enter an amount to deposit : ");
					account2.deposit(input.nextDouble()); break;
				}
				break;
			case 3 :  
				printMenu();
				System.out.print("Enter a choice : ");
				menu = input.nextInt();
				switch(menu){
				case 1 : 
					System.out.print("The balance is " + account3.getBalance() + "\n"); break;
				case 2 : 
					System.out.print("Enter an amount to withdraw : ");
					account3.withdraw(input.nextDouble()); break;
				case 3 : 
					System.out.print("Enter an amount to deposit : ");
					account3.deposit(input.nextDouble()); break;
				}
				break;
			case 4 :  
				printMenu();
				System.out.print("Enter a choice : ");
				menu = input.nextInt();
				switch(menu){
				case 1 : 
					System.out.print("The balance is " + account4.getBalance() + "\n"); break;
				case 2 : 
					System.out.print("Enter an amount to withdraw : ");
					account4.withdraw(input.nextDouble()); break;
				case 3 : 
					System.out.print("Enter an amount to deposit : ");
					account4.deposit(input.nextDouble()); break;
				}
				break;
			case 5 :  
				printMenu();
				System.out.print("Enter a choice : ");
				menu = input.nextInt();
				switch(menu){
				case 1 : 
					System.out.print("The balance is " + account5.getBalance() + "\n"); break;
				case 2 : 
					System.out.print("Enter an amount to withdraw : ");
					account5.withdraw(input.nextDouble()); break;
				case 3 : 
					System.out.print("Enter an amount to deposit : ");
					account5.deposit(input.nextDouble()); break;
				}
				break;
			case 6 :  
				printMenu();
				System.out.print("Enter a choice : ");
				menu = input.nextInt();
				switch(menu){
				case 1 : 
					System.out.print("The balance is " + account6.getBalance() + "\n"); break;
				case 2 : 
					System.out.print("Enter an amount to withdraw : ");
					account6.withdraw(input.nextDouble()); break;
				case 3 : 
					System.out.print("Enter an amount to deposit : ");
					account6.deposit(input.nextDouble()); break;
				}
				break;
			case 7 :  
				printMenu();
				System.out.print("Enter a choice : ");
				menu = input.nextInt();
				switch(menu){
				case 1 : 
					System.out.print("The balance is " + account7.getBalance() + "\n"); break;
				case 2 : 
					System.out.print("Enter an amount to withdraw : ");
					account7.withdraw(input.nextDouble()); break;
				case 3 : 
					System.out.print("Enter an amount to deposit : ");
					account7.deposit(input.nextDouble()); break;
				}
				break;
			case 8 :  
				printMenu();
				System.out.print("Enter a choice : ");
				menu = input.nextInt();
				switch(menu){
				case 1 : 
					System.out.print("The balance is " + account8.getBalance() + "\n"); break;
				case 2 : 
					System.out.print("Enter an amount to withdraw : ");
					account8.withdraw(input.nextDouble()); break;
				case 3 : 
					System.out.print("Enter an amount to deposit : ");
					account8.deposit(input.nextDouble()); break;
				}
				break;
			case 9 :  
				printMenu();
				System.out.print("Enter a choice : ");
				menu = input.nextInt();
				switch(menu){
				case 1 : 
					System.out.print("The balance is " + account9.getBalance() + "\n"); break;
				case 2 : 
					System.out.print("Enter an amount to withdraw : ");
					account9.withdraw(input.nextDouble()); break;
				case 3 : 
					System.out.print("Enter an amount to deposit : ");
					account9.deposit(input.nextDouble()); break;
				}
				break;
			}//Big switch end
			
			if(menu == 4){
				do {
					System.out.print("Emter an id(0~9) : ");
					temp = input.nextInt();
				} while ((temp < 0) || (9 < temp)); // check id
			}//if end
		}while(menu != 5);
		System.out.print("Finish\n");
	}//main end	
}//Ass6_9_7 end

class Account{
	public int id = 0;
	public double balance = 0;
	public double annualInterestRate = 0;
	public Date dataCreated = new Date();
	
	public Account() {}
	
	public Account(int id, double balance){
		this.id = id;
		this.balance = balance;
	}
	
	public void setId(int id){
		this.id = id;
	}
	
	public int getId(){
		return id;
	}
	
	public void setBalance(double balance){
		this.balance = balance;
	}
	
	public double getBalance(){
		return balance;
	}
	
	public void setAnnualInterestRate(double annualInterestRate){
		this.annualInterestRate = annualInterestRate;
	}
	
	public double getAnnualInterestRate(){
		return annualInterestRate;
	}
	
	public double getMonthlyInterestRate(){
		return annualInterestRate / 12;
	}
	
	public void withdraw(double amount){
		balance -= amount;
	}
	
	public void deposit(double amount){
		balance += amount;
	}
	
	public Date getDataCreated(){
		return dataCreated;
	}
}//Account end

